import router from '@system.router'

var counter = 3;
var timer = null;

export default {
    data: {
        imgsrc: "",
        seconds: ""
    },
    run() {
        counter--;
        if (counter != 0) {
            this.imgsrc = "/common/" + counter.toString() + ".png";
            this.seconds = counter.toString();
        } else {
            this.imgsrc = "";
            this.seconds = "0";

            clearInterval(timer);
            timer = null;

            router.replace({
                uri: 'pages/xunlian/xunlian',
                params: {
                    "data1": this.data1,
                    "data2": this.data2
                }
            })
        }
    },
    onInit() {
        this.imgsrc = "/common/" + counter.toString() + ".png";
        this.seconds = counter.toString();
    },
    onShow() {
        timer = setInterval(this.run,1000);
    }
}
